OB.MesActionButton = OB.MesActionButton || {};

// BOM上传图片查看
OB.MesActionButton.uploadFile = function(params, win) {
    var viewGrid = win.activeView.viewGrid;
    var record = viewGrid.getSelectedRecord();
    if (record) {
        OB.MesActionButton.refreshView = function () {
            win.refresh();
        }
        OB.RemoteCallManager.call("com.basis.handler.FileUploadHandler", {}, {tabId: win.activeView.tabId, type: 'getItem'},
            function(response, data, request) {
                if (data.result) {
                    OB.MesActionButton.uploadData = data;
                    OB.Layout.ClassicOBCompatibility.Popup.open(
                        "file_Upload_Popup", 500, 200,
                        OB.Application.contextUrl + "web/com.basic/html/fileUpload.jsp?tabId=" + win.activeView.tabId +
                        "&dataId=" + record.id + "&names=" + data.names + "&fields=" + data.fields,
                        name, window, false, false, null, true, true);
                } else {
                    isc.showMessage(data.msg, top.isc.OBMessageBar.TYPE_ERROR);
                }
            }
        );
    } else {
        isc.showMessage("请选择记录！");
    }
};

//BOM查看文件
OB.MesActionButton.showUploadFile = function(params, win) {
    var viewGrid = win.activeView.viewGrid;
    var record = viewGrid.getSelectedRecord();
    if(a == null || a._entityName != 'Emes_PBom_Item_Shape'){
        top.isc.showMessage("请选择一条有效记录。",top.isc.OBMessageBar.TYPE_SUCCESS);
        return false;
    }
    if(a.dataFilePath == null){
        top.isc.showMessage("未上传文件。",top.isc.OBMessageBar.TYPE_SUCCESS);
        return;
    }

    isc.EMES_Window_View.create({url: "DownFileServlet.html?path=" + encodeURIComponent(a.dataFilePath) + "&online=true&fileName=" + encodeURIComponent(a.fileName)}).show();

}